<template>
  <work-template v-model="detailForm" @submitOn="submitOn"
                 @closeSelectedTag="closeSelectedTag"
                  :butShow="true">
    <div slot="form" class="container-div">
      <repair v-model="detailForm" ref="refRepair"/>
    </div>
  </work-template>
</template>

<script>

import * as apis from "@/api/warning"
export default {
  name: '',
  components: {
    repair: () => import('./repair.vue')
  },
  computed: {},
  watch: {},
  data() {
    return {
      detailForm: {
        rows: []
      }
    };
  },
  created() {
    this.handleList()
  },
  methods: {
    async handleList() {
      try {
        let res = await apis?.list({configType: 6})
        this.detailForm.rows = res.rows || []
      } catch (e) {
        console.error(e)
      }
    },

    async submitOn() {
      let loading = null
      try {
        await this.$refs.refRepair.handleEffect()
        loading = this.$loading({
          lock: true,
          text: "保存中",
          spinner: "el-icon-loading",
          background: "rgba(0, 0, 0, 0.7)",
        });
        let res = await apis?.carWarnConfig(this.detailForm.rows)
        if (res.code === 200) {
          this.$message.success('修改成功')
          this.handleList()
        }

      } catch (e) {
        console.error(e)
      } finally {
        loading?.close();
      }
    },

    closeSelectedTag() {
      this.handleList()
      this.$modal.msgSuccess('取消成功')
    }
  },
};
</script>

<style scoped lang="">

</style>


